from pyspark import SparkConf, SparkContext
import os

os.environ['PYSPARK_PYTHON'] = r"D://Python/Python3107/python.exe"
os.environ['HADOOP_HOME'] = r"D://Tools/Hadoop/hadoop-3.3.5."
conf = SparkConf().setMaster("local[*]").setAppName("test_spark")
conf.set("spark.default.parallelism", "1")
sc = SparkContext(conf=conf)


rdd1 = sc.parallelize([1,2,3,4,5,6,7,8,9,10])
rdd2 = sc.parallelize([("Hello", 3), ("World", 5), ("Python", 7)])
rdd3 = sc.parallelize([[1, 2, 3], [4, 5, 6], [7, 8, 9]])
rdd4 = sc.parallelize([{"a":1}, {"b":2}, {"c":3}])

rdd1.saveAsTextFile(r"D://itheima/Python/pyspark案例/output1")
rdd2.saveAsTextFile(r"D://itheima/Python/pyspark案例/output2")
rdd3.saveAsTextFile(r"D://itheima/Python/pyspark案例/output3")
rdd4.saveAsTextFile(r"D://itheima/Python/pyspark案例/output4")


